﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace StockMentor
{
    public class Conexiune
    {
        private static SqlConnection connection;
        public static SqlConnection InitializeazaCnx(string sConnString)
        {
            try
            {
                connection = new SqlConnection();
                connection.ConnectionString = sConnString;
                return connection;
            }
            catch
            {
                MessageBox.Show("Eroare deschidere conexiune!");
                return new SqlConnection();
            }
        }

        public static void DeschideCnx(SqlConnection conn)
        {

            if (conn.State == ConnectionState.Closed )
                conn.Open();
        }

        public static void InchideCnx(SqlConnection conn)
        {

            if (conn.State == ConnectionState.Open)
                conn.Close();
        }
    }
}
